const express = require('express');
const app = express();
const path = require('path');
app.listen(3000,()=>{
    console.log('打开3000端口');
});

let login = require('./route/login.js');
app.use(login);

let register = require('./route/register.js');
app.use(register);

app.use((err,req,res,next)=>{
    console.log(err);
    res.status(555);
    res.send(`<h1>${err}</h1>`);
});

app.use((req,res)=>{
    // res.status(404);//设置状态码
    // res.send({
    //     status:404,
    //     code:'not found',
    // });
    //方式二: 返回html页给用户看
    res.status(404);
    let pathUrl = path.join(__dirname,'./views/404.html')
    res.sendFile(pathUrl);
});